//父类
class Person {
    constructor(name) {
        this.name = name;
    }
    eat() {
        console.log(`${this.name} ,吃东西了`);

    }
}

//子类--学生类
class Student extends Person {
    constructor(name, age) {
        super(name);
        this.age = age;
    }
    sayhi() {
        console.log(`${this.name},今年 ${this.age} 岁了`);

    }
}

//子类--老师类
class Teacher extends Person {
    constructor(name, sub) {
        super(name);
        //把name给Person 的constructor 
        this.sub = sub;
    }
    teach() {
        console.log(`${this.name}  教 ${this.sub} 课`);
    }
}

const zby = new Student('zby', 18);
console.log(zby.name);
console.log(zby.age);
zby.sayhi();

const aaa = new Teacher('aaa', '数学');
console.log(aaa.name);
console.log(aaa.sub);
aaa.teach();

